package com.rtx.edi.platform.express.auth.service.impl;

import java.util.List;

import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.rtx.edi.model.express.auth.dto.PlAuthAppDto;
import com.rtx.edi.model.express.auth.po.PlAuthApp;
import com.rtx.edi.platform.express.auth.mapper.PlAuthAppMapper;
import com.rtx.edi.platform.express.auth.service.PlAuthAppService;

/**
 * 应用信息 维护
 * @author luoqiongli
 *
 */
@Service
public class PlAuthAppServiceImpl extends ServiceImpl<PlAuthAppMapper,PlAuthApp> implements PlAuthAppService {

	@Override
	public void selectPlAuthApp(Page<PlAuthApp> pageParam, PlAuthApp app) {
		LambdaQueryWrapper<PlAuthApp> query = Wrappers.lambdaQuery();
		query.eq(PlAuthApp::getDeleteflag,"0");
		if(app!=null) {
			query.like(StringUtils.hasText(app.getName()),PlAuthApp::getName,app.getName())
			.eq(app.getType()!=null, PlAuthApp::getType, app.getType())
			.eq(app.getAppkey()!=null,PlAuthApp::getAppkey,app.getAppkey())
			.eq(app.getAppsecret()!=null,PlAuthApp::getAppsecret,app.getAppsecret())
			.eq(app.getGetway()!=null,PlAuthApp::getGetway,app.getGetway())
			.eq(app.getAuthurl()!=null,PlAuthApp::getAuthurl,app.getAuthurl())
			;
		}
		baseMapper.selectPage(pageParam,query);
		
	}

	@Override
	public Boolean addPlAuthApp(PlAuthApp app) {
		
		return baseMapper.addPlAuthApp(app)==1;
	}

	@Override
	public void delPlAuthApps(List<PlAuthAppDto> list) {
		for (PlAuthAppDto dto : list) {
			baseMapper.deleteById(dto.getId());
		}
	}
	

}
